import axios from 'axios'

const ACHIEVEMENT_API_URL = '/api/achievements'

/**
 * 学生API服务
 */
class StudentService {
  /**
   * 获取学生的所有成果
   */
  getMyAchievements(params?: any) {
    return axios.get(`${ACHIEVEMENT_API_URL}/my`, { params })
  }

  /**
   * 获取成果统计信息
   */
  getAchievementStats() {
    return axios.get(`${ACHIEVEMENT_API_URL}/stats`)
  }

  /**
   * 根据ID获取成果详情
   */
  getAchievementById(type: string, id: number) {
    return axios.get(`${ACHIEVEMENT_API_URL}/${type}/${id}`)
  }

  /**
   * 创建新成果
   */
  createAchievement(achievementData: any) {
    return axios.post(`${ACHIEVEMENT_API_URL}`, achievementData)
  }

  /**
   * 更新成果
   */
  updateAchievement(type: string, id: number, achievementData: any) {
    return axios.put(`${ACHIEVEMENT_API_URL}/${type}/${id}`, achievementData)
  }

  /**
   * 删除成果
   */
  deleteAchievement(type: string, id: number) {
    return axios.delete(`${ACHIEVEMENT_API_URL}/${type}/${id}`)
  }
}

export default new StudentService() 